class Solution
{
public:
    vector<int> minSubsequence(vector<int> &nums)
    {
        sort(nums.begin(), nums.end());
        int sum = accumulate(nums.begin(), nums.end(), 0);
        int selected = 1;
        int n = nums.size();
        int selectedSum = nums[n - selected];
        int leftSum = sum - selectedSum;
        while (selectedSum <= leftSum)
        {
            ++selected;
            leftSum -= nums[n - selected];
            selectedSum += nums[n - selected];
        }
        return vector<int>(nums.rbegin(), nums.rbegin() + selected);
    }
};